
package com.smth.infobox;

import com.smth.infobox.compoments.*;

import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;

public class Infobox extends BaseWebViewActivity {
    /** Called when the activity is first created. */
    public static String URL_STRING = "url_string";
    public static String IS_URL = "is_url";
    boolean isURL;
    private String home;

    private boolean progressSet = false;

    private void setProgress() {
        if (!progressSet) {
            setProgressBarIndeterminateVisibility(true);
            progressSet = true;
        }
    }

    private void unsetProgress() {
        if (progressSet) {
            setProgressBarIndeterminateVisibility(false);
            progressSet = false;
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        webView.setWebViewClient(new BaseWebViewClient(this));
        home = getIntent().getStringExtra(URL_STRING);
        isURL = getIntent().getBooleanExtra(IS_URL, true);
        loadHome();
    }

    private void loadHome() {
        if (isURL) {
            setProgress();
            webView.loadUrl(home);
        } else {
            Log.e("loadData", "" + home.length());
            webView.loadData(home, "text/html", "utf-8");
        }

    }

    @Override
    public void onResume() {
        super.onResume();
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onRestoreInstanceState(Bundle state) {
        super.onRestoreInstanceState(state);

    }
}
